<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8">
<title>BagUtils (Apache Commons Collections 4.0 API)</title>
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
    if (location.href.indexOf('is-external=true') == -1) {
        parent.document.title="BagUtils (Apache Commons Collections 4.0 API)";
    }
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!--   -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!--   -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/BagUtils.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../org/apache/commons/collections4/Bag.html" title="interface in org.apache.commons.collections4"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../org/apache/commons/collections4/BidiMap.html" title="interface in org.apache.commons.collections4"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/apache/commons/collections4/BagUtils.html" target="_top">Frames</a></li>
<li><a href="BagUtils.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_top");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#field_summary">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#field_detail">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_top">
<!--   -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.apache.commons.collections4</div>
<h2 title="Class BagUtils" class="title">Class BagUtils</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li><a href="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</a></li>
<li>
<ul class="inheritance">
<li>org.apache.commons.collections4.BagUtils</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public class <span class="strong">BagUtils</span>
extends <a href="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></pre>
<div class="block">Provides utility methods and decorators for <a href="../../../../org/apache/commons/collections4/Bag.html" title="interface in org.apache.commons.collections4"><code>Bag</code></a> and <a href="../../../../org/apache/commons/collections4/SortedBag.html" title="interface in org.apache.commons.collections4"><code>SortedBag</code></a> instances.</div>
<dl><dt><span class="strong">Since:</span></dt>
  <dd>2.1</dd>
<dt><span class="strong">Version:</span></dt>
  <dd>$Id: BagUtils.java 1543964 2013-11-20 21:53:39Z tn $</dd></dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- =========== FIELD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="field_summary">
<!--   -->
</a>
<h3>Field Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Field Summary table, listing fields, and an explanation">
<caption><span>Fields</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Field and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static <a href="../../../../org/apache/commons/collections4/Bag.html" title="interface in org.apache.commons.collections4">Bag</a></code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/commons/collections4/BagUtils.html#EMPTY_BAG">EMPTY_BAG</a></strong></code>
<div class="block">An empty unmodifiable bag.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static <a href="../../../../org/apache/commons/collections4/Bag.html" title="interface in org.apache.commons.collections4">Bag</a></code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/commons/collections4/BagUtils.html#EMPTY_SORTED_BAG">EMPTY_SORTED_BAG</a></strong></code>
<div class="block">An empty unmodifiable sorted bag.</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method_summary">
<!--   -->
</a>
<h3>Method Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span>Methods</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static &lt;E&gt;&nbsp;<a href="../../../../org/apache/commons/collections4/Bag.html" title="interface in org.apache.commons.collections4">Bag</a>&lt;E&gt;</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/commons/collections4/BagUtils.html#collectionBag(org.apache.commons.collections4.Bag)">collectionBag</a></strong>(<a href="../../../../org/apache/commons/collections4/Bag.html" title="interface in org.apache.commons.collections4">Bag</a>&lt;E&gt;&nbsp;bag)</code>
<div class="block">Returns a bag that complies to the Collection contract, backed by the given bag.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static &lt;E&gt;&nbsp;<a href="../../../../org/apache/commons/collections4/Bag.html" title="interface in org.apache.commons.collections4">Bag</a>&lt;E&gt;</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/commons/collections4/BagUtils.html#emptyBag()">emptyBag</a></strong>()</code>
<div class="block">Get an empty <code>Bag</code>.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static &lt;E&gt;&nbsp;<a href="../../../../org/apache/commons/collections4/SortedBag.html" title="interface in org.apache.commons.collections4">SortedBag</a>&lt;E&gt;</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/commons/collections4/BagUtils.html#emptySortedBag()">emptySortedBag</a></strong>()</code>
<div class="block">Get an empty <code>SortedBag</code>.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static &lt;E&gt;&nbsp;<a href="../../../../org/apache/commons/collections4/Bag.html" title="interface in org.apache.commons.collections4">Bag</a>&lt;E&gt;</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/commons/collections4/BagUtils.html#predicatedBag(org.apache.commons.collections4.Bag, org.apache.commons.collections4.Predicate)">predicatedBag</a></strong>(<a href="../../../../org/apache/commons/collections4/Bag.html" title="interface in org.apache.commons.collections4">Bag</a>&lt;E&gt;&nbsp;bag,
             <a href="../../../../org/apache/commons/collections4/Predicate.html" title="interface in org.apache.commons.collections4">Predicate</a>&lt;? super E&gt;&nbsp;predicate)</code>
<div class="block">Returns a predicated (validating) bag backed by the given bag.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static &lt;E&gt;&nbsp;<a href="../../../../org/apache/commons/collections4/SortedBag.html" title="interface in org.apache.commons.collections4">SortedBag</a>&lt;E&gt;</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/commons/collections4/BagUtils.html#predicatedSortedBag(org.apache.commons.collections4.SortedBag, org.apache.commons.collections4.Predicate)">predicatedSortedBag</a></strong>(<a href="../../../../org/apache/commons/collections4/SortedBag.html" title="interface in org.apache.commons.collections4">SortedBag</a>&lt;E&gt;&nbsp;bag,
                   <a href="../../../../org/apache/commons/collections4/Predicate.html" title="interface in org.apache.commons.collections4">Predicate</a>&lt;? super E&gt;&nbsp;predicate)</code>
<div class="block">Returns a predicated (validating) sorted bag backed by the given sorted
 bag.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static &lt;E&gt;&nbsp;<a href="../../../../org/apache/commons/collections4/Bag.html" title="interface in org.apache.commons.collections4">Bag</a>&lt;E&gt;</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/commons/collections4/BagUtils.html#synchronizedBag(org.apache.commons.collections4.Bag)">synchronizedBag</a></strong>(<a href="../../../../org/apache/commons/collections4/Bag.html" title="interface in org.apache.commons.collections4">Bag</a>&lt;E&gt;&nbsp;bag)</code>
<div class="block">Returns a synchronized (thread-safe) bag backed by the given bag.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static &lt;E&gt;&nbsp;<a href="../../../../org/apache/commons/collections4/SortedBag.html" title="interface in org.apache.commons.collections4">SortedBag</a>&lt;E&gt;</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/commons/collections4/BagUtils.html#synchronizedSortedBag(org.apache.commons.collections4.SortedBag)">synchronizedSortedBag</a></strong>(<a href="../../../../org/apache/commons/collections4/SortedBag.html" title="interface in org.apache.commons.collections4">SortedBag</a>&lt;E&gt;&nbsp;bag)</code>
<div class="block">Returns a synchronized (thread-safe) sorted bag backed by the given
 sorted bag.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static &lt;E&gt;&nbsp;<a href="../../../../org/apache/commons/collections4/Bag.html" title="interface in org.apache.commons.collections4">Bag</a>&lt;E&gt;</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/commons/collections4/BagUtils.html#transformingBag(org.apache.commons.collections4.Bag, org.apache.commons.collections4.Transformer)">transformingBag</a></strong>(<a href="../../../../org/apache/commons/collections4/Bag.html" title="interface in org.apache.commons.collections4">Bag</a>&lt;E&gt;&nbsp;bag,
               <a href="../../../../org/apache/commons/collections4/Transformer.html" title="interface in org.apache.commons.collections4">Transformer</a>&lt;? super E,? extends E&gt;&nbsp;transformer)</code>
<div class="block">Returns a transformed bag backed by the given bag.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static &lt;E&gt;&nbsp;<a href="../../../../org/apache/commons/collections4/SortedBag.html" title="interface in org.apache.commons.collections4">SortedBag</a>&lt;E&gt;</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/commons/collections4/BagUtils.html#transformingSortedBag(org.apache.commons.collections4.SortedBag, org.apache.commons.collections4.Transformer)">transformingSortedBag</a></strong>(<a href="../../../../org/apache/commons/collections4/SortedBag.html" title="interface in org.apache.commons.collections4">SortedBag</a>&lt;E&gt;&nbsp;bag,
                     <a href="../../../../org/apache/commons/collections4/Transformer.html" title="interface in org.apache.commons.collections4">Transformer</a>&lt;? super E,? extends E&gt;&nbsp;transformer)</code>
<div class="block">Returns a transformed sorted bag backed by the given bag.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static &lt;E&gt;&nbsp;<a href="../../../../org/apache/commons/collections4/Bag.html" title="interface in org.apache.commons.collections4">Bag</a>&lt;E&gt;</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/commons/collections4/BagUtils.html#unmodifiableBag(org.apache.commons.collections4.Bag)">unmodifiableBag</a></strong>(<a href="../../../../org/apache/commons/collections4/Bag.html" title="interface in org.apache.commons.collections4">Bag</a>&lt;? extends E&gt;&nbsp;bag)</code>
<div class="block">Returns an unmodifiable view of the given bag.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static &lt;E&gt;&nbsp;<a href="../../../../org/apache/commons/collections4/SortedBag.html" title="interface in org.apache.commons.collections4">SortedBag</a>&lt;E&gt;</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/commons/collections4/BagUtils.html#unmodifiableSortedBag(org.apache.commons.collections4.SortedBag)">unmodifiableSortedBag</a></strong>(<a href="../../../../org/apache/commons/collections4/SortedBag.html" title="interface in org.apache.commons.collections4">SortedBag</a>&lt;E&gt;&nbsp;bag)</code>
<div class="block">Returns an unmodifiable view of the given sorted bag.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods_inherited_from_class_java.lang.Object">
<!--   -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.<a href="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></h3>
<code><a href="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang">clone</a>, <a href="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang">equals</a>, <a href="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang">finalize</a>, <a href="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass</a>, <a href="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode</a>, <a href="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify</a>, <a href="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll</a>, <a href="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString</a>, <a href="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait</a>, <a href="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait</a>, <a href="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long, int)" title="class or interface in java.lang">wait</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ FIELD DETAIL =========== -->
<ul class="blockList">
<li class="blockList"><a name="field_detail">
<!--   -->
</a>
<h3>Field Detail</h3>
<a name="EMPTY_BAG">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>EMPTY_BAG</h4>
<pre>public static final&nbsp;<a href="../../../../org/apache/commons/collections4/Bag.html" title="interface in org.apache.commons.collections4">Bag</a> EMPTY_BAG</pre>
<div class="block">An empty unmodifiable bag.</div>
</li>
</ul>
<a name="EMPTY_SORTED_BAG">
<!--   -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>EMPTY_SORTED_BAG</h4>
<pre>public static final&nbsp;<a href="../../../../org/apache/commons/collections4/Bag.html" title="interface in org.apache.commons.collections4">Bag</a> EMPTY_SORTED_BAG</pre>
<div class="block">An empty unmodifiable sorted bag.</div>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method_detail">
<!--   -->
</a>
<h3>Method Detail</h3>
<a name="synchronizedBag(org.apache.commons.collections4.Bag)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>synchronizedBag</h4>
<pre>public static&nbsp;&lt;E&gt;&nbsp;<a href="../../../../org/apache/commons/collections4/Bag.html" title="interface in org.apache.commons.collections4">Bag</a>&lt;E&gt;&nbsp;synchronizedBag(<a href="../../../../org/apache/commons/collections4/Bag.html" title="interface in org.apache.commons.collections4">Bag</a>&lt;E&gt;&nbsp;bag)</pre>
<div class="block">Returns a synchronized (thread-safe) bag backed by the given bag. In
 order to guarantee serial access, it is critical that all access to the
 backing bag is accomplished through the returned bag.
 <p>
 It is imperative that the user manually synchronize on the returned bag
 when iterating over it:

 <pre>
 Bag bag = BagUtils.synchronizedBag(new HashBag());
 ...
 synchronized(bag) {
     Iterator i = bag.iterator(); // Must be in synchronized block
     while (i.hasNext())
         foo(i.next());
     }
 }
 </pre>

 Failure to follow this advice may result in non-deterministic behavior.</div>
<dl><dt><span class="strong">Type Parameters:</span></dt><dd><code>E</code> - the element type</dd><dt><span class="strong">Parameters:</span></dt><dd><code>bag</code> - the bag to synchronize, must not be null</dd>
<dt><span class="strong">Returns:</span></dt><dd>a synchronized bag backed by that bag</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="http://download.oracle.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if the Bag is null</dd></dl>
</li>
</ul>
<a name="unmodifiableBag(org.apache.commons.collections4.Bag)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>unmodifiableBag</h4>
<pre>public static&nbsp;&lt;E&gt;&nbsp;<a href="../../../../org/apache/commons/collections4/Bag.html" title="interface in org.apache.commons.collections4">Bag</a>&lt;E&gt;&nbsp;unmodifiableBag(<a href="../../../../org/apache/commons/collections4/Bag.html" title="interface in org.apache.commons.collections4">Bag</a>&lt;? extends E&gt;&nbsp;bag)</pre>
<div class="block">Returns an unmodifiable view of the given bag. Any modification attempts
 to the returned bag will raise an <a href="http://download.oracle.com/javase/6/docs/api/java/lang/UnsupportedOperationException.html?is-external=true" title="class or interface in java.lang"><code>UnsupportedOperationException</code></a>.</div>
<dl><dt><span class="strong">Type Parameters:</span></dt><dd><code>E</code> - the element type</dd><dt><span class="strong">Parameters:</span></dt><dd><code>bag</code> - the bag whose unmodifiable view is to be returned, must not be null</dd>
<dt><span class="strong">Returns:</span></dt><dd>an unmodifiable view of that bag</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="http://download.oracle.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if the Bag is null</dd></dl>
</li>
</ul>
<a name="predicatedBag(org.apache.commons.collections4.Bag, org.apache.commons.collections4.Predicate)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>predicatedBag</h4>
<pre>public static&nbsp;&lt;E&gt;&nbsp;<a href="../../../../org/apache/commons/collections4/Bag.html" title="interface in org.apache.commons.collections4">Bag</a>&lt;E&gt;&nbsp;predicatedBag(<a href="../../../../org/apache/commons/collections4/Bag.html" title="interface in org.apache.commons.collections4">Bag</a>&lt;E&gt;&nbsp;bag,
                       <a href="../../../../org/apache/commons/collections4/Predicate.html" title="interface in org.apache.commons.collections4">Predicate</a>&lt;? super E&gt;&nbsp;predicate)</pre>
<div class="block">Returns a predicated (validating) bag backed by the given bag.
 <p>
 Only objects that pass the test in the given predicate can be added to
 the bag. Trying to add an invalid object results in an
 IllegalArgumentException. It is important not to use the original bag
 after invoking this method, as it is a backdoor for adding invalid
 objects.</div>
<dl><dt><span class="strong">Type Parameters:</span></dt><dd><code>E</code> - the element type</dd><dt><span class="strong">Parameters:</span></dt><dd><code>bag</code> - the bag to predicate, must not be null</dd><dd><code>predicate</code> - the predicate for the bag, must not be null</dd>
<dt><span class="strong">Returns:</span></dt><dd>a predicated bag backed by the given bag</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="http://download.oracle.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if the Bag or Predicate is null</dd></dl>
</li>
</ul>
<a name="transformingBag(org.apache.commons.collections4.Bag, org.apache.commons.collections4.Transformer)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>transformingBag</h4>
<pre>public static&nbsp;&lt;E&gt;&nbsp;<a href="../../../../org/apache/commons/collections4/Bag.html" title="interface in org.apache.commons.collections4">Bag</a>&lt;E&gt;&nbsp;transformingBag(<a href="../../../../org/apache/commons/collections4/Bag.html" title="interface in org.apache.commons.collections4">Bag</a>&lt;E&gt;&nbsp;bag,
                         <a href="../../../../org/apache/commons/collections4/Transformer.html" title="interface in org.apache.commons.collections4">Transformer</a>&lt;? super E,? extends E&gt;&nbsp;transformer)</pre>
<div class="block">Returns a transformed bag backed by the given bag.
 <p>
 Each object is passed through the transformer as it is added to the Bag.
 It is important not to use the original bag after invoking this method,
 as it is a backdoor for adding untransformed objects.
 <p>
 Existing entries in the specified bag will not be transformed.
 If you want that behaviour, see <a href="../../../../org/apache/commons/collections4/bag/TransformedBag.html#transformedBag(org.apache.commons.collections4.Bag, org.apache.commons.collections4.Transformer)"><code>TransformedBag.transformedBag(Bag, Transformer)</code></a>.</div>
<dl><dt><span class="strong">Type Parameters:</span></dt><dd><code>E</code> - the element type</dd><dt><span class="strong">Parameters:</span></dt><dd><code>bag</code> - the bag to predicate, must not be null</dd><dd><code>transformer</code> - the transformer for the bag, must not be null</dd>
<dt><span class="strong">Returns:</span></dt><dd>a transformed bag backed by the given bag</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="http://download.oracle.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if the Bag or Transformer is null</dd></dl>
</li>
</ul>
<a name="collectionBag(org.apache.commons.collections4.Bag)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>collectionBag</h4>
<pre>public static&nbsp;&lt;E&gt;&nbsp;<a href="../../../../org/apache/commons/collections4/Bag.html" title="interface in org.apache.commons.collections4">Bag</a>&lt;E&gt;&nbsp;collectionBag(<a href="../../../../org/apache/commons/collections4/Bag.html" title="interface in org.apache.commons.collections4">Bag</a>&lt;E&gt;&nbsp;bag)</pre>
<div class="block">Returns a bag that complies to the Collection contract, backed by the given bag.</div>
<dl><dt><span class="strong">Type Parameters:</span></dt><dd><code>E</code> - the element type</dd><dt><span class="strong">Parameters:</span></dt><dd><code>bag</code> - the bag to decorate, must not be null</dd>
<dt><span class="strong">Returns:</span></dt><dd>a Bag that complies to the Collection contract</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="http://download.oracle.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if bag is null</dd><dt><span class="strong">Since:</span></dt>
  <dd>4.0</dd></dl>
</li>
</ul>
<a name="synchronizedSortedBag(org.apache.commons.collections4.SortedBag)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>synchronizedSortedBag</h4>
<pre>public static&nbsp;&lt;E&gt;&nbsp;<a href="../../../../org/apache/commons/collections4/SortedBag.html" title="interface in org.apache.commons.collections4">SortedBag</a>&lt;E&gt;&nbsp;synchronizedSortedBag(<a href="../../../../org/apache/commons/collections4/SortedBag.html" title="interface in org.apache.commons.collections4">SortedBag</a>&lt;E&gt;&nbsp;bag)</pre>
<div class="block">Returns a synchronized (thread-safe) sorted bag backed by the given
 sorted bag. In order to guarantee serial access, it is critical that all
 access to the backing bag is accomplished through the returned bag.
 <p>
 It is imperative that the user manually synchronize on the returned bag
 when iterating over it:

 <pre>
 SortedBag bag = BagUtils.synchronizedSortedBag(new TreeBag());
 ...
 synchronized(bag) {
     Iterator i = bag.iterator(); // Must be in synchronized block
     while (i.hasNext())
         foo(i.next());
     }
 }
 </pre>

 Failure to follow this advice may result in non-deterministic behavior.</div>
<dl><dt><span class="strong">Type Parameters:</span></dt><dd><code>E</code> - the element type</dd><dt><span class="strong">Parameters:</span></dt><dd><code>bag</code> - the bag to synchronize, must not be null</dd>
<dt><span class="strong">Returns:</span></dt><dd>a synchronized bag backed by that bag</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="http://download.oracle.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if the SortedBag is null</dd></dl>
</li>
</ul>
<a name="unmodifiableSortedBag(org.apache.commons.collections4.SortedBag)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>unmodifiableSortedBag</h4>
<pre>public static&nbsp;&lt;E&gt;&nbsp;<a href="../../../../org/apache/commons/collections4/SortedBag.html" title="interface in org.apache.commons.collections4">SortedBag</a>&lt;E&gt;&nbsp;unmodifiableSortedBag(<a href="../../../../org/apache/commons/collections4/SortedBag.html" title="interface in org.apache.commons.collections4">SortedBag</a>&lt;E&gt;&nbsp;bag)</pre>
<div class="block">Returns an unmodifiable view of the given sorted bag. Any modification
 attempts to the returned bag will raise an
 <a href="http://download.oracle.com/javase/6/docs/api/java/lang/UnsupportedOperationException.html?is-external=true" title="class or interface in java.lang"><code>UnsupportedOperationException</code></a>.</div>
<dl><dt><span class="strong">Type Parameters:</span></dt><dd><code>E</code> - the element type</dd><dt><span class="strong">Parameters:</span></dt><dd><code>bag</code> - the bag whose unmodifiable view is to be returned, must not be null</dd>
<dt><span class="strong">Returns:</span></dt><dd>an unmodifiable view of that bag</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="http://download.oracle.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if the SortedBag is null</dd></dl>
</li>
</ul>
<a name="predicatedSortedBag(org.apache.commons.collections4.SortedBag, org.apache.commons.collections4.Predicate)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>predicatedSortedBag</h4>
<pre>public static&nbsp;&lt;E&gt;&nbsp;<a href="../../../../org/apache/commons/collections4/SortedBag.html" title="interface in org.apache.commons.collections4">SortedBag</a>&lt;E&gt;&nbsp;predicatedSortedBag(<a href="../../../../org/apache/commons/collections4/SortedBag.html" title="interface in org.apache.commons.collections4">SortedBag</a>&lt;E&gt;&nbsp;bag,
                                   <a href="../../../../org/apache/commons/collections4/Predicate.html" title="interface in org.apache.commons.collections4">Predicate</a>&lt;? super E&gt;&nbsp;predicate)</pre>
<div class="block">Returns a predicated (validating) sorted bag backed by the given sorted
 bag.
 <p>
 Only objects that pass the test in the given predicate can be added to
 the bag. Trying to add an invalid object results in an
 IllegalArgumentException. It is important not to use the original bag
 after invoking this method, as it is a backdoor for adding invalid
 objects.</div>
<dl><dt><span class="strong">Type Parameters:</span></dt><dd><code>E</code> - the element type</dd><dt><span class="strong">Parameters:</span></dt><dd><code>bag</code> - the sorted bag to predicate, must not be null</dd><dd><code>predicate</code> - the predicate for the bag, must not be null</dd>
<dt><span class="strong">Returns:</span></dt><dd>a predicated bag backed by the given bag</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="http://download.oracle.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if the SortedBag or Predicate is null</dd></dl>
</li>
</ul>
<a name="transformingSortedBag(org.apache.commons.collections4.SortedBag, org.apache.commons.collections4.Transformer)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>transformingSortedBag</h4>
<pre>public static&nbsp;&lt;E&gt;&nbsp;<a href="../../../../org/apache/commons/collections4/SortedBag.html" title="interface in org.apache.commons.collections4">SortedBag</a>&lt;E&gt;&nbsp;transformingSortedBag(<a href="../../../../org/apache/commons/collections4/SortedBag.html" title="interface in org.apache.commons.collections4">SortedBag</a>&lt;E&gt;&nbsp;bag,
                                     <a href="../../../../org/apache/commons/collections4/Transformer.html" title="interface in org.apache.commons.collections4">Transformer</a>&lt;? super E,? extends E&gt;&nbsp;transformer)</pre>
<div class="block">Returns a transformed sorted bag backed by the given bag.
 <p>
 Each object is passed through the transformer as it is added to the Bag.
 It is important not to use the original bag after invoking this method,
 as it is a backdoor for adding untransformed objects.
 <p>
 Existing entries in the specified bag will not be transformed.
 If you want that behaviour, see
 <a href="../../../../org/apache/commons/collections4/bag/TransformedSortedBag.html#transformedSortedBag(org.apache.commons.collections4.SortedBag, org.apache.commons.collections4.Transformer)"><code>TransformedSortedBag.transformedSortedBag(SortedBag, Transformer)</code></a>.</div>
<dl><dt><span class="strong">Type Parameters:</span></dt><dd><code>E</code> - the element type</dd><dt><span class="strong">Parameters:</span></dt><dd><code>bag</code> - the bag to predicate, must not be null</dd><dd><code>transformer</code> - the transformer for the bag, must not be null</dd>
<dt><span class="strong">Returns:</span></dt><dd>a transformed bag backed by the given bag</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="http://download.oracle.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if the Bag or Transformer is null</dd></dl>
</li>
</ul>
<a name="emptyBag()">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>emptyBag</h4>
<pre>public static&nbsp;&lt;E&gt;&nbsp;<a href="../../../../org/apache/commons/collections4/Bag.html" title="interface in org.apache.commons.collections4">Bag</a>&lt;E&gt;&nbsp;emptyBag()</pre>
<div class="block">Get an empty <code>Bag</code>.</div>
<dl><dt><span class="strong">Type Parameters:</span></dt><dd><code>E</code> - the element type</dd>
<dt><span class="strong">Returns:</span></dt><dd>an empty Bag</dd></dl>
</li>
</ul>
<a name="emptySortedBag()">
<!--   -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>emptySortedBag</h4>
<pre>public static&nbsp;&lt;E&gt;&nbsp;<a href="../../../../org/apache/commons/collections4/SortedBag.html" title="interface in org.apache.commons.collections4">SortedBag</a>&lt;E&gt;&nbsp;emptySortedBag()</pre>
<div class="block">Get an empty <code>SortedBag</code>.</div>
<dl><dt><span class="strong">Type Parameters:</span></dt><dd><code>E</code> - the element type</dd>
<dt><span class="strong">Returns:</span></dt><dd>an empty sorted Bag</dd></dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!--   -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!--   -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/BagUtils.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../org/apache/commons/collections4/Bag.html" title="interface in org.apache.commons.collections4"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../org/apache/commons/collections4/BidiMap.html" title="interface in org.apache.commons.collections4"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/apache/commons/collections4/BagUtils.html" target="_top">Frames</a></li>
<li><a href="BagUtils.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_bottom");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#field_summary">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#field_detail">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_bottom">
<!--   -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>Copyright &#169; 2001&#x2013;2013 <a href="http://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p>
</body>
</html>
